#include "stdafx.h"

/* JIST:    SWAP like bubble, where bigger value bubbles up to the end for every iteration
            n iterations will sequential swapping checking for non decreasing order
            on any non swap iteration, list is considered sorted.
   Psuedo:  Considering decreasing ordered list, 
            Outer loop i: 0 to n-1
                Inner loop j: 0 to n-i-1
                    Swap on condition violation of order
                
*/

// one complete iteration of swap will bring bigger value to t

Find the largest element and place them in the end 
// Outer loop visits all the elements and places the sorted element in the last few c
// Inner loop keeps swapping

void Swap(long arr[], long pos1, long pos2)
{
    long temp = arr[pos1];
    arr[pos1] = arr[pos2];
    arr[pos2] = temp;
}

void BubbleSort(long arr[], long size)
{

}

int _tmain(int argc, _TCHAR* argv[])
{
    long arr[] = {64, 34, 25, 12, 22, 11, 90};
    long n = sizeof(arr)/sizeof(arr[0]);
    
    BubbleSort(arr, n);    

    printf("Sorted array: \n");
    for (int ind = 0; ind < n; ind++)
        printf("%d ", arr[ind]);
    printf("\n");

    getchar();
	return 0;
}

